//
//  WXIllegalProcessingTableViewCell.m
//  CarJX
//
//  Created by jxcl on 14-9-17.
//  Copyright (c) 2014年 KK. All rights reserved.
//

#import "WXIllegalProcessingTableViewCell.h"

@implementation WXIllegalProcessingTableViewCell

- (void)awakeFromNib
{
     self.layer.masksToBounds = YES;
   self.layer.cornerRadius = 20.0f;
    self.backgroundColor = UICOLOR_MAKE_RGB(255, 255, 240);

}
- (void)violationBtnRequest:(BOOL) bol{
    
    if (bol) {
        if ([self viewWithTag:101] == nil) {
            UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"19_3_4@2x"]];
            image.tag = 101;
            [image setFrame:(CGRect){ {10,5} , {18 , 18} }];
            [self.violationBtn addSubview:image];
         }else{
  
            
        }
    }else{
        if ([self viewWithTag:101] != nil) {
             UIImageView *image = (UIImageView *)[self viewWithTag:101];
            [image removeFromSuperview];
        }
        
    }
    
}


- (void) violationBtn:(id)sender{
    
    
    if ([self viewWithTag:101] == nil) {
         UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"19_3_4@2x"]];
        image.tag = 101;
        [image setFrame:(CGRect){ {10,5} , {18 , 18} }];
        [_violationBtn addSubview:image];
        NSDictionary *dic = @{@"price" : _fine.text , @"id" : _Id , @"tag" : [NSString stringWithFormat:@"%d",self.tag], @"repet" : @"0"};
        
        
        [[NSNotificationCenter defaultCenter] postNotificationName:@"cellSelete" object:dic];
        
    }else{
        UIImageView *image = (UIImageView *)[self viewWithTag:101];
        [image removeFromSuperview];
        NSDictionary *dic = @{@"price" : _fine.text , @"id" : _Id , @"tag" : [NSString stringWithFormat:@"%d",self.tag], @"repet" : @"1"};
        
        
        [[NSNotificationCenter defaultCenter] postNotificationName:@"cellSelete" object:dic];
        
     }
    
}




- (void) setviolationLabel:(NSDictionary *)dic andNum:(NSInteger) num andId:(NSString *)Id{
    
    self.Id = Id;
    
    
    [_violationBtn setImage:[UIImage imageNamed:@"19_3_5.png"] forState:UIControlStateNormal];
    
    
    _illegalPlace.text = [dic objectForKey:@"ADDRESS"];
    
    _fine.text = [dic objectForKey:@"PRICE"];
    
    _reducePoints.text = [dic objectForKey:@"SCORE"];
    
    _violationTime.text = [[[dic objectForKey:@"TIME"] componentsSeparatedByString:@" "] objectAtIndex:0];
    
    if (_label) {
        [_label removeFromSuperview];
    }
    
    [_image setImage: [UIImage imageNamed:@"19_3_19"]];
    if ([NSString stringWithFormat:@"%ld",(long)num]) {
        CGRect labelRect = _image.bounds;
        
        if (num > 9) {
            labelRect.origin = CGPointMake(3, _image.bounds.origin.y);

        }else{
        labelRect.origin = CGPointMake(8, _image.bounds.origin.y);
        }
        _label = [[UILabel alloc] initWithFrame:labelRect];
        
        _label.text = [NSString stringWithFormat:@"%ld",(long)num];
        [_image addSubview:_label];
    }
    
    
 }
- (void) setHadLoginviolationLabel:(NSDictionary *)dic andNum:(NSInteger) num andId:(NSString *)Id{
    
    self.Id = Id;
    
    
    [_violationBtn setImage:[UIImage imageNamed:@"19_3_5.png"] forState:UIControlStateNormal];
    
    
    _illegalPlace.text = [dic objectForKey:@"address"];
    
    _fine.text = [dic objectForKey:@"price"];
    
    _reducePoints.text = [dic objectForKey:@"score"];
    
    _violationTime.text = [[[dic objectForKey:@"time"] componentsSeparatedByString:@" "] objectAtIndex:0];
    
    if (_label) {
        [_label removeFromSuperview];
    }
    
    [_image setImage: [UIImage imageNamed:@"19_3_19"]];
    if ([NSString stringWithFormat:@"%d",num]) {
        CGRect labelRect = _image.bounds;
        if (num > 9) {
            labelRect.origin = CGPointMake(3, _image.bounds.origin.y);
            
        }else{
            labelRect.origin = CGPointMake(8, _image.bounds.origin.y);
        }
        _label = [[UILabel alloc] initWithFrame:labelRect];
        
        _label.text = [NSString stringWithFormat:@"%d",num];
        [_image addSubview:_label];
    }
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

     }


@end
